package com.xhwl.centiotdata.service.integrateconfig;

import com.xhwl.centiotdata.service.cent.ICentSecurityService;
import com.xhwl.common.enums.CategoryEnum;
import com.xhwl.common.enums.ProductEnum;
import com.xhwl.common.enums.centsecurity.CameraSubscribeTypeEnum;
import com.xhwl.common.pojo.cent.device.DeviceProjSupplierCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Falcon.cao @Copyright (C), 2022, 兴海物联
 * Date: 2022/6/21 10:16
 * Description: 包信息
 */
@Component
public class MonitorIntegrationConfig {

    @Autowired
    private ICentSecurityService centSecurityService;

    @EventListener
    public void listenIntegrationConfig(IntegrationConfigEvent event) {
        List<DeviceProjSupplierCategory> collect = IntegrationConfig.integrationConfigList.stream()
                .filter(deviceProjSupplierCategory -> CategoryEnum.MONITOR.getId().equals(deviceProjSupplierCategory.getProdCategoryId()))
                .collect(Collectors.toList());

        collect.forEach(deviceProjSupplierCategory -> {
            if (ProductEnum.HUAWEI_IVS3800.getId().equals(deviceProjSupplierCategory.getProductId())) {
                centSecurityService.subscribes(deviceProjSupplierCategory.getProjectId(), CameraSubscribeTypeEnum.VEHICLE_ENTRANCE.getType());
                centSecurityService.subscribes(deviceProjSupplierCategory.getProjectId(), CameraSubscribeTypeEnum.VCM_FACE.getType());
            }
        });
    }


}
